<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<%@ include file="/commons/validation.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>费用</title>
<script type="text/javascript">

  function submitForm(){
  var isTrue=$("editForm").fireEvent("onSubmit");
    if(isTrue){
     document.getElementById("serviceItemType1").disabled=false;
      document.getElementById("serviceItemType2").disabled=false;
    document.getElementById("editForm").action="${ctx}/customerService_dispatchFormAction.do?method=${flat}ChargeItem";
     document.getElementById("editForm").submit();
   }
  }

  function selectChargeType(){
    if(document.getElementById("serviceItemType1").checked){
        alert("暂时不提供物料的选择");
    }
    if(document.getElementById("serviceItemType2").checked){
    var url = "${ctx}/charge_chargeStandardAction.do?method=queryChargeSelectList";
		top.windowOpen(url, "serviceItemSelect", "服务项目选择", 420, 750,true,"serviceItemSelect");

    }
  }

  function setChargeItem(staName,price){
  document.getElementById("name").value=staName;
  document.getElementById("price").value=price;
  }

  function autoSum(){
   var price=document.getElementById("price").value;
   var customerUsage=document.getElementById("customerUsage").value;

   if(isNaN(price)==false && isNaN(customerUsage)==false){
     if(price=='' || customerUsage==''){
      document.getElementById("fee").value='';
       return false;
     }
      document.getElementById("fee").value=parseFloat(Number(price)*Number(customerUsage)).toFixed(2);
   }
  }

  function setDisableType(){

   if(document.getElementById("serviceItemType1").checked){
    document.getElementById("handBack").disabled=false;
    document.getElementById("preDraw").disabled=false;
   }

   if(document.getElementById("serviceItemType2").checked){
   document.getElementById("handBack").value="";
    document.getElementById("preDraw").value="";
    document.getElementById("handBack").disabled=true;
    document.getElementById("preDraw").disabled=true;
   }

  }


</script>
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><span class="window_head_intext"><img src="${ctx}/images/ico_Advance.gif" align="absmiddle" />
    <c:if test="${flat=='add'}">增加费用</c:if>
     <c:if test="${flat=='edit'}">修改费用</c:if>
        </span></td>
      </tr>
    </table>

  </tr>
  <tr>
    <td colspan="2" class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td colspan="2" class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td colspan="2" class="content"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="aux_outtable_color"><table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
      <form id="editForm" name="editForm" method="post" action="#" class="required-validate">
           <input type="hidden" name="dispatchFormId" value="${dispatchFormId}">
            <input type="hidden" name="keyword" value="${chargeItemId}">

          <tr>
		  <td class="aux_intable_td1">费用类型：</td>
            <td class="aux_intable_td2" ><input name="serviceItemType" id="serviceItemType1" type="radio" value="1" ${selectItemType=='1'?'checked':'' } onClick="setDisableType();" ${flat=='edit'?'disabled':''}>
              物 料&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="radio" name="serviceItemType" id="serviceItemType2" value="2" onClick="setDisableType();" ${selectItemType=='2'?'checked':'' } ${flat=='edit'?'disabled':''}>
                服务费</td>

            <td class="aux_intable_td1">退还数量：</td>
            <td class="aux_intable_td2"><input name="handBack" type="text" class="int-right max-value-32767" value="${entryVO.handBack}" size="16" style="text-align:right" maxLength="36"/>          </tr>
          <tr >
            <td class="aux_intable_td1">编 号：</td>
            <td class="aux_intable_td2"><input name="code" type="text" class="inputtext" value="${entryVO.code}" size="16" maxLength="36"/></td>
            <td class="aux_intable_td1">单 价：</td>
            <td class="aux_intable_td2"><input name="price" type="text" onblur="autoSum();" class="integer-decimal-range-18-2 float-right" value="${entryVO.price=='0.00'?'':entryVO.price}" size="16" style="text-align:right"/></td>
          </tr>
          <tr id="tr01">
            <td class="aux_intable_td1">名 称：</td>
            <td width="10%" class="aux_intable_require" >
			<table border="0" cellspacing="0" cellpadding="0" id="layer1" >
                       <tr>
                          <td >
                            <input name="name" type="text" class="required" value="${entryVO.name}" size="16" maxLength="36" afterInsert="tempInsert"/>
                          </td>
                          <td width="4">&nbsp;</td>
                          <td   onFocus="this.blur()"><img onClick="selectChargeType();" style="cursor:hand" src="${ctx}/images/ico_cz.gif" width="16" height="16" border="0" /><span id="tempInsert"></span></td>
                       </tr>
            </table>
			</td>
            <td valign="top" class="aux_intable_td1">金 额：</td>
            <td class="aux_intable_td2"><input name="fee" type="text" readOnly class="integer-decimal-range-18-2" value="${entryVO.fee=='0.00'?'':entryVO.fee}" size="16" style="text-align:right"/></td>
          </tr>

          <tr>
            <td class="aux_intable_td1">预计用量：</td>
            <td class="aux_intable_td2"><table border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td><input name="preDraw" type="text" class="int-right max-value-32767" value="${entryVO.preDraw}" size="16" style="text-align:right"/></td>
                  <td width="4">&nbsp;</td>

                </tr>
            </table></td>
            <td rowspan="2" valign="top" class="aux_intable_td1">备 注：</td>
            <td rowspan="2" valign="top" class="aux_intable_td2">
              <textarea name="remark" cols="20" class="max-length-200">${entryVO.remark}</textarea></td>
          </tr>
		  <tr>
            <td valign="top" class="aux_intable_td1">实际用量：</td>
            <td valign="top" class="aux_intable_td2"><input onblur="autoSum();" name="customerUsage" type="text" class="int-right max-value-32767" value="${entryVO.customerUsage}" size="16" style="text-align:right"/>            </td>
            </tr>

       </form>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>

    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0" >
            <tr>
              <td class="buttonOffLeft" id="btn1_11"></td>
              <td class="buttonOffMiddle" id="btn1_12" onClick="submitForm();" onMouseOver="btn_change_over(1)" onMouseOut="btn_change_out(1)" onBlur="btn_change(1)"><img src="${ctx}/images/ico_ok.gif" border="0" align="absmiddle" /> 保 存</td>
              <td class="buttonOffRight" id="btn1_13"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onClick=" windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onBlur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 关 闭</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
      </tr>
    </table>
    <p>&nbsp;</p></td>
  </tr>
</table>
</body>
<script type="text/javascript">

setDisableType();
</script>
</html>